import sphRequest from '@/utils/sphRequest'

/**
 * 登录的路由接口
 * POST /api/user/passport/login
 */

export interface loginInfo {
  phone: string | number
  password: string | number
}

export const getUserLogin = async (loginInfo1: loginInfo) => {
  return await sphRequest.post(`/api/user/passport/login`, loginInfo1)
}

/**
 * 获取购物车数据
 * GET /api/cart/cartList
 */
interface cartListData {
  data: cartData[]
}

interface cartData {
  cartInfoList: cartItem[]
}

interface cartItem {
  id: any
  userId: any
  skuId: any
  cartPrice: any
  skuNum: any
  imgUrl: any
  skuName: any
  isChecked: any
  skuPrice: any
}

export const getCartListData = async () => {
  return await sphRequest.get<any, cartListData>(`/api/cart/cartList`)
}

/**
 * 删除单个商品的接口函数
 * DELETE/api/cart/deleteCart/{skuId}
 */

export const getDeleteGoods = async (skuId: any) => {
  return await sphRequest.delete<any, null>(`/api/cart/deleteCart/${skuId}`)
}
